/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package com.iss.examsys.ejb;

import com.iss.examsys.entity.Question;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.TypedQuery;

/**
 *
 * @author Quek Ting Hong
 */
@Stateless
public class QuestionBean {
    @PersistenceContext EntityManager em;
    
    public void createModule(Question question){
        em.persist(question);
    }
    
    public List<Question> findAllQuestions(){
        TypedQuery<Question> result = em.createNamedQuery("Question.findAll", Question.class);
        
        return result.getResultList();
    }
    
    public Question find(Long id) {
        return em.find(Question.class, id);
    }
}
